import Mock from 'mockjs'
import qs from 'qs'
const req = context => context.keys().map(context)
const options = req(require.context('./api/', true, /\.js$/))
  .filter(e => e.default)
  .map(e => e.default)
options.forEach(option => {
  option.forEach(({ path, method, handle }) => {
    Mock.mock(path, method, typeof handle === 'function' ? o => { console.log(o); o.body = JSON.parse(o.body); return handle(o) } : handle)
  })
})
